from django.middleware.common import MiddlewareMixin
from django.http import QueryDict

class PutMiddlerWare(MiddlewareMixin):

    def process_request(self,request):
        if request.method.upper() == "PUT":
            content_type = request.META.get("CONTENT_TYPE")
            if "multipart" in content_type: #form-data
                data,files = request.parse_file_upload(request.META,request)
                request.PUT = data
                request._files = files
            else:
                data = QueryDict(request.body)
                request.PUT = data